#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
ll num[200010];
ll pre[200010];
const ll mod=(1e+9)+7;

ll f(ll a,ll b){
    ll sum=0;
    while(b){
        if(b&1){
            sum=(sum+a)%mod;
        }
        b>>=1;
        a=(a+a)%mod;
    }
    return sum;
}

int main()
{
    IOS;
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>num[i];
    }    
    for(ll i=1;i<=n;i++){
        pre[i]=pre[i-1]+num[i];
    }
    ll ans=0;
    for(ll i=n;i>1;i--){
        ans=(ans+f(pre[i-1],num[i]))%mod;
    }
    cout<<ans<<endl;
    getchar();
    getchar();
    return 0;
}
